package com.xnyzc.lhy.mis.mapper.area;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xnyzc.lhy.mis.entity.area.OaSysArea;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 区域表 Mapper 接口
 * </p>
 *
 * @author liuju
 * @since 2019-08-12
 */
public interface OaSysAreaMapper extends BaseMapper<OaSysArea> {

    /**
     * 查询城市
     * @return
     */
    @Select("SELECT  " +
            "oa_sys_area.area_id,  " +
            "oa_sys_area.parent_id,   " +
            "oa_sys_area.name,   " +
            "oa_sys_area.ad_code,  " +
            "oa_sys_area.city_code,   " +
            "oa_sys_area.type   " +
            "FROM   " +
            "oa_sys_area    " +
            "WHERE   " +
            "deleted = 0    " +
            "AND parent_id =1  ")
    List<HashMap<String,Object>> allCityGroup();


    /**
     * 查询非城市
     * @return
     */
    @Select("SELECT  " +
            "oa_sys_area.area_id,  " +
            "oa_sys_area.parent_id,   " +
            "oa_sys_area.name,   " +
            "oa_sys_area.ad_code,  " +
            "oa_sys_area.city_code,   " +
            "oa_sys_area.type   " +
            "FROM   " +
            "oa_sys_area    " +
            "WHERE   " +
            "deleted = 0    " +
            "AND parent_id <>1   " +
            "AND parent_id <>0    ")
    List<HashMap<String,Object>> allCityChild();

    @Select("select osa.name,osa.ad_code FROM  oa_sys_area as osa \n" +
            "RIGHT JOIN oa_sys_bill_rule_group as osb on osb.city_id = osa.ad_code")
    List<OaSysArea> getAllUsedCity();
}
